<?php

/**
 * @author Martin Pernica
 * @copyright 2008
 */
echo '<a href="index.php?p=components&amp;name=user">Zpět</a><br />';

if (!empty($_POST['username'])) {
    $query = $GLOBALS['db']->query("SELECT id, username FROM {prefix}users WHERE username LIKE '" .
        $_POST['username'] . "'");
    if ((int)$query->num_rows != 0) {
        echo '<table cellspacing="20" cellpadding="30" class="clean_table">';
        echo '<tr><th>ID</th><th>'.USER_USERNAME.'</th><th>'.ACTION.'</th></tr>';
        while ($data = $query->fetch_array()) {
            echo '<tr><td>' . $data['id'] . '</td><td>' . $data['username'] .
                '<td><a href="index.php?p=components&name=user&a=delete&id=' . $data['id'] .
                '"><img src="../libs/icons/delete.png" /></a>&nbsp;&nbsp;<a href="index.php?p=components&name=user&a=edit&id=' .
                $data['id'] . '"><img src="../libs/icons/style_edit.png" /></td>';
        }
        echo '</table>';
    } else {
        echo '<p><strong>Nenalezeno !</strong></p>';
    }
}
if (!empty($_POST['display_name'])) {
    $query = $GLOBALS['db']->query("SELECT id, display_name FROM {prefix}users WHERE display_name LIKE '" .
        $_POST['display_name'] . "'");
    if ((int)$query->num_rows != 0) {
        echo '<table cellspacing="20" cellpadding="30" class="clean_table">';
        echo '<tr><th>ID</th><th>'.USER_NICKNAME.'</th><th>'.ACTION.'</th></tr>';
        while ($data = $query->fetch_array()) {
            echo '<tr><td>' . $data['id'] . '</td><td>' . $data['display_name'] .
                '<td><a href="index.php?p=components&name=user&a=delete&id=' . $data['id'] .
                '"><img src="../libs/icons/delete.png" /></a>&nbsp;&nbsp;<a href="index.php?p=components&name=user&a=edit&id=' .
                $data['id'] . '"><img src="../libs/icons/style_edit.png" /></td>';
        }
        echo '</table>';
    } else {
        echo '<p><strong>Nenalezeno !</strong></p>';
    }
}
if (!empty($_POST['email'])) {
    $query = $GLOBALS['db']->query("SELECT id, email, display_name FROM {prefix}users WHERE email LIKE '" .
        $_POST['email'] . "'");
    if ((int)$query->num_rows != 0) {
        echo '<table cellspacing="20" cellpadding="30" class="clean_table">';
        echo '<tr><th>ID</th><th>'.USER.'</th><th>'.USER_EMAIL.'</th><th>'.ACTION.'</th></tr>';
        while ($data = $query->fetch_array()) {
            echo '<tr><td>' . $data['id'] . '</td><td>' . $data['display_name'] .
                '</td><td>' . $data['email'] .
                '<td><a href="index.php?p=components&name=user&a=delete&id=' . $data['id'] .
                '"><img src="../libs/icons/delete.png" /></a>&nbsp;&nbsp;<a href="index.php?p=components&name=user&a=edit&id=' .
                $data['id'] . '"><img src="../libs/icons/style_edit.png" /></td>';
        }
        echo '</table>';
    } else {
        echo '<p><strong>Nenalezeno !</strong></p>';
    }
}
echo '<br /><form action="" method="post"><table>';
echo '
	
	<tr><td>'.USER_SEARCH_USERNAME.' : <input type="text" name="username" /> <input type="submit" value="' .
    SUBMIT . '" />
</td></tr>';

echo '
	<tr><td>'.USER_SEARCH_NICKNAME.' : <input type="text" name="display_name" /> <input type="submit" value="' .
    SUBMIT . '" />
	</td></tr>';

echo '
	<tr><td>'.USER_SEARCH_EMAIL.' : <input type="text" name="email" /> <input type="submit" value="' .
    SUBMIT . '" />
	</td></tr>
	
	</table></form>';

?>